#ifndef CSE168_MATERIAL_H_INCLUDED
#define CSE168_MATERIAL_H_INCLUDED

#include "Miro.h"
#include "Vector3.h"
#include "Ray.h"
#include "LightPath.h"
#include <stdlib.h>

class Material
{
public:
    Material();
    virtual ~Material();

    virtual void preCalc() {}
    
    virtual Vector3 shade(const Ray& ray, const HitInfo& hit, char rayCount, const Scene& scene,
    		 	 	 	 int mode=RAYTRACE, Vector3 rayColor=Vector3(1), bool diffuseRay=false) const;

    virtual void handlePhoton(const Ray& ray, const HitInfo& hit, char rayCount, Vector3 photonFlux, const Scene& scene,
    					 	  int mode=APPM_PHOTON, LightPath *lp=0) const;

	static Vector3 randDir(Vector3 n, const Ray& r, float u1=-10, float u2=-10)
	{
		Vector3 dir = Rand::getRandDir(n, u1, u2);

		if (dot(r.d, n)>0)
			dir = -1*dir;

		return dir;
	}

};

#endif // CSE168_MATERIAL_H_INCLUDED
